#ifndef RING_H_
#define RING_H_
/*********************************************************/

#include <string>
#include <vector>
#include <Poco/Mutex.h>
/*********************************************************/
struct RingNode {
	std::string 			addr;
	std::vector<std::string>	clients;
};
/*********************************************************/
class Ring
{
private:
	// Variables
	mutable Poco::Mutex		mutex;
	std::string			ringName;		// Name of the ring
	std::string			ringAddr;		// The multicast address this ring is operating on
	std::vector<RingNode>		ring;			// Stores all nodes that are in the ring


protected:
public:
	// Methods
	std::string getName() const;				// Returns the ring name
	std::string getAddr() const;				// Returns the ring multicast group
	void setName(const std::string&);			// Sets the ring name
	void setAddr(const std::string&);			// Sets the ring address ( multicast group )

	void addNode(const std::string&);			// Adds a new server to this ring
	void removeNode(const std::string&);			// Remove a server from this ring
	std::string addClient(const std::string&);		// Adds a new client connection to this ring, returning the node it should connect to
	void removeClient(const std::string&);			// Remove a client connection

	unsigned int size() const;				// Returns the amount of servers currently in the ring
	unsigned int load() const;				// Returns the amount of clients connected to this ring
	std::string loadOverview() const;			// Returns a string containing a load overview for this ring

	// Construction & Destruction
	Ring();
	Ring(const Ring&);
	Ring& operator=(const Ring&);
	~Ring();
};
/*********************************************************/
#endif // RING_H_
